	function fSubmitLogin() {
		login.getForm().submit({
			method : 'POST',
      url : 'auth.php',
			waitTitle : "Please Wait",
			waitMsg :"Verifing username and password",
			success : function(loginForm, resp) {
        console.log(resp);
				Ext.Msg.wait("Redirecting please wait...", "Redirecting");
				SideBar_RedirectUrl = '/index.php';
				setTimeout( "window.location.href = SideBar_RedirectUrl", 0 );
			},
			failure : function(form, action) {
				if (action.failureType == 'server') {
					obj = Ext.util.JSON.decode(action.response.responseText);
					Ext.MessageBox.show({
					   title: "Login Failed",
					   msg: obj.response,
					   buttons: Ext.MessageBox.OK,
					   icon: Ext.MessageBox.ERROR
				   });
				} else {
					Ext.MessageBox.show({
					   title: "Login Failed",
					   msg: action.response.responseText,
					   buttons: Ext.MessageBox.OK,
					   icon: Ext.MessageBox.WARNING
					});
				}
			}
		});
	}



	var login = new Ext.FormPanel(

		{
			labelWidth : 80,
			id: 'frmLogin',
			url : 'auth.php',
			frame : true,
			border : false,
			title : "Crab MYSQL Authentification",
			defaultType : 'textfield',
			renderTo : 'extjs-login-form',
			width : 345,
			height : 125,
			iconCls: 'silk-key',
			items : [ {
				fieldLabel : "Username",
				name : 'loginUsername',
				width: 240,
				allowBlank: true
			}, {
				fieldLabel : "Password",
				name : 'loginPassword',
				inputType : 'password',
				width: 240,
				allowBlank: true
			} ],



			// All the magic happens after the user clicks the button

			buttons : [ {
				text : 'Login',
				// Function that fires when user clicks the button
				handler : fSubmitLogin
			} ],
			keys: [{ key: [Ext.EventObject.ENTER], handler: fSubmitLogin  }]
		});

